package com.wanglibao.woodtrade.woodtrade.model.impl;

import android.content.Context;

import com.wanglibao.woodtrade.woodtrade.model.City;
import com.wanglibao.woodtrade.woodtrade.model.db.BaseDao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lugg on 2016/5/19.
 */
public class CityImpl extends BaseDao<City,String> {
    public CityImpl(Context context) {
        super(context, City.class);
    }

    public List<City> getCityByRegionId(String regionId){
        List<City> citys = new ArrayList<>();
        try {
            citys = dao.queryForEq("parent_id",regionId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return citys;
    }

    public static String[] getStrings(List<City> cityList){
        String[] citys = new String[cityList.size()];
        for (int i = 0; i < cityList.size(); i++){
            citys[i] = cityList.get(i).region_name;
        }
        return citys;
    }
}
